Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds the ONNX export of GeoCalib's perspective field network used by COLMAP, a verification script against the PyTorch implementation, and a CI workflow.
Contents
onnx/export.pyexports GeoCalib's feed-forward perspective field estimation network (MSCANbackbone +LowLevelEncoder+PerspectiveDecoder):image (1, 3, H, W)float32 in[0, 1]with dynamicheightandwidthdivisible by 32.up_field (1, 2, H, W),up_confidence (1, 1, H, W),latitude_field (1, 1, H, W), andlatitude_confidence (1, 1, H, W).GeoCalib.predict_fieldsingeocalib/geocalib.pyencapsulates the feed-forward perspective field prediction and is shared betweenGeoCalib.forwardandPerspectiveFieldsONNX.NMF2D.freeze_bases(GeoCalib.freeze_nmf_bases) fixes the initial NMF basis to a deterministic buffer (Noneby default, so default PyTorch behavior is unchanged).LightHamHead.forwardusesscale_factor=float(2**i)(and identity fori == 0), which is bit-for-bit identical in PyTorch while supporting dynamic spatial dimensions natively in ONNX.onnx/check.pychecks any exported ONNX model against a PyTorch checkpoint (--weights) across the 4 asset images in landscape, portrait (rot90), and square aspect ratios:up_field,latitude_field,up_confidence, andlatitude_confidencepredictions (<= 6.3e-6max error on CPU).vfov, radial distortionk1) and gravity (roll,pitch) optimized byLMOptimizerfrom the ONNX-predicted perspective fields vs. PyTorch (<= 2.7e-5 degon CPU)..github/workflows/onnx_export.yml):geocalib/,onnx/,requirements.txt, orpyproject.toml.geocalib_distorted.onnxon CPU and checks it against PyTorch withonnx/check.py.COLMAP integration: colmap/colmap#4797.